package com.niiwoo.civet.trade.enums;

import com.niiwoo.civet.trade.constant.TradeRedisKey;
import com.niiwoo.tripod.provider.exception.NoSuchEnumValueException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 原投资筛选、自动、批量投资选择有投资类型，实际与标的类型是一致的。现弃用，使用com.niiwoo.civet.trade.enums.ProjectTypeEnum
 * Created by zhangwanli on 2017/11/8.
 */
@Getter
@AllArgsConstructor
@Deprecated
public enum InvestTypeEnum {
    PERSONAL_SPEEDLOAN((byte) 1, "极速借个人"),
    ORG_SPEEDLOAN((byte) 2, "极速借机构"),
    YUNDAI((byte) 3, "你我云贷"),
    CARD_EASY_LOAN((byte) 4, "卡易借");

    private final Byte value;
    private final String desc;

    public static InvestTypeEnum enumOf(Byte value) {
        for (InvestTypeEnum typeEnum : values()) {
            if (typeEnum.value.equals(value)) {
                return typeEnum;
            }
        }
        throw new NoSuchEnumValueException("InvestTypeEnum:" + value);
    }

    public static String getAutoInvestorQueueName(Byte typeValue) {
        if (typeValue == null) {
            return null;
        }
        return getAutoInvestorQueueNameByTypeEnum(InvestTypeEnum.enumOf(typeValue));
    }

    public static String getAutoInvestorQueueNameByTypeEnum(InvestTypeEnum type) {
        //ZWL LTS
        if (type == null) {
            return null;
        }
        String queueName;
        switch (type) {
            case PERSONAL_SPEEDLOAN:
                queueName = TradeRedisKey.PERSONAL_SPEEDLOAN_AUTO_INVESTORS;
                break;
            case ORG_SPEEDLOAN:
                queueName = TradeRedisKey.ORG_SPEEDLOAN_AUTO_INVESTORS;
                break;
            case YUNDAI:
                queueName = TradeRedisKey.YUNDAI_AUTO_INVESTORS;
                break;
            case CARD_EASY_LOAN:
                queueName = TradeRedisKey.CARD_EASY_LOAN_AUTO_INVESTORS;
                break;
            default:
                queueName = null;
        }
        return queueName;
    }

}
